<?php
/**
 * 城市地址api管理
 * Created by Sublime Text 3.
 * @authors Rejeo (rejeo@qq.com)
 * @date    2018-04-22 23:20:45
 */
namespace app\api\controller;

use think\Controller;
use think\Request;
use app\common\model\City as CityModel;

class City extends Controller
{
    private $link;

    // 重载父类的初始化设置
    public function _initialize()
    {
        $this->link = new CityModel();
    }

    // 显示地址列表
    public function getCitysByParentId(Request $request)
    {
        $parentId = intval($request->get('id', 0, ''));

        if (0>=$parentId) {
            // 返回封装后的 API 数据到客户端
            $this->result(['data'=>[],'code'=>0,'msg'=>'获取失败！']);
        }
        $res = $this->link->getCitysToParentId($parentId);
        // dump($res);exit;
        if ($res) {
            $this->result($res, 1, '获取成功！');
        }
        $this->result(['data'=>[],'code'=>0,'msg'=>'获取失败！']);
    }

}
